<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>container.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_ui_container.js.html">container.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Base class for containers that host {@link goog.ui.Control}s,
<a name="line17"></a> * such as menus and toolbars.  Provides default keyboard and mouse event
<a name="line18"></a> * handling and child management, based on a generalized version of
<a name="line19"></a> * {@link goog.ui.Menu}.
<a name="line20"></a> *
<a name="line21"></a> * @author attila@google.com (Attila Bodis)
<a name="line22"></a> * @see ../demos/container.html
<a name="line23"></a> */
<a name="line24"></a>// TODO(attila):  Fix code/logic duplication between this and goog.ui.Control.
<a name="line25"></a>// TODO(attila):  Maybe pull common stuff all the way up into Component...?
<a name="line26"></a>
<a name="line27"></a>goog.provide(&#39;goog.ui.Container&#39;);
<a name="line28"></a>goog.provide(&#39;goog.ui.Container.EventType&#39;);
<a name="line29"></a>goog.provide(&#39;goog.ui.Container.Orientation&#39;);
<a name="line30"></a>
<a name="line31"></a>goog.require(&#39;goog.a11y.aria&#39;);
<a name="line32"></a>goog.require(&#39;goog.a11y.aria.State&#39;);
<a name="line33"></a>goog.require(&#39;goog.asserts&#39;);
<a name="line34"></a>goog.require(&#39;goog.dom&#39;);
<a name="line35"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line36"></a>goog.require(&#39;goog.events.KeyCodes&#39;);
<a name="line37"></a>goog.require(&#39;goog.events.KeyHandler&#39;);
<a name="line38"></a>goog.require(&#39;goog.object&#39;);
<a name="line39"></a>goog.require(&#39;goog.style&#39;);
<a name="line40"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line41"></a>goog.require(&#39;goog.ui.ContainerRenderer&#39;);
<a name="line42"></a>goog.require(&#39;goog.ui.Control&#39;);
<a name="line43"></a>
<a name="line44"></a>
<a name="line45"></a>
<a name="line46"></a>/**
<a name="line47"></a> * Base class for containers.  Extends {@link goog.ui.Component} by adding
<a name="line48"></a> * the following:
<a name="line49"></a> *  &lt;ul&gt;
<a name="line50"></a> *    &lt;li&gt;a {@link goog.events.KeyHandler}, to simplify keyboard handling,
<a name="line51"></a> *    &lt;li&gt;a pluggable &lt;em&gt;renderer&lt;/em&gt; framework, to simplify the creation of
<a name="line52"></a> *        containers without the need to subclass this class,
<a name="line53"></a> *    &lt;li&gt;methods to manage child controls hosted in the container,
<a name="line54"></a> *    &lt;li&gt;default mouse and keyboard event handling methods.
<a name="line55"></a> *  &lt;/ul&gt;
<a name="line56"></a> * @param {?goog.ui.Container.Orientation=} opt_orientation Container
<a name="line57"></a> *     orientation; defaults to {@code VERTICAL}.
<a name="line58"></a> * @param {goog.ui.ContainerRenderer=} opt_renderer Renderer used to render or
<a name="line59"></a> *     decorate the container; defaults to {@link goog.ui.ContainerRenderer}.
<a name="line60"></a> * @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for document
<a name="line61"></a> *     interaction.
<a name="line62"></a> * @extends {goog.ui.Component}
<a name="line63"></a> * @constructor
<a name="line64"></a> */
<a name="line65"></a>goog.ui.Container = function(opt_orientation, opt_renderer, opt_domHelper) {
<a name="line66"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line67"></a>  this.renderer_ = opt_renderer || goog.ui.ContainerRenderer.getInstance();
<a name="line68"></a>  this.orientation_ = opt_orientation || this.renderer_.getDefaultOrientation();
<a name="line69"></a>};
<a name="line70"></a>goog.inherits(goog.ui.Container, goog.ui.Component);
<a name="line71"></a>
<a name="line72"></a>
<a name="line73"></a>/**
<a name="line74"></a> * Container-specific events.
<a name="line75"></a> * @enum {string}
<a name="line76"></a> */
<a name="line77"></a>goog.ui.Container.EventType = {
<a name="line78"></a>  /**
<a name="line79"></a>   * Dispatched after a goog.ui.Container becomes visible. Non-cancellable.
<a name="line80"></a>   * NOTE(user): This event really shouldn&#39;t exist, because the
<a name="line81"></a>   * goog.ui.Component.EventType.SHOW event should behave like this one. But the
<a name="line82"></a>   * SHOW event for containers has been behaving as other components&#39;
<a name="line83"></a>   * BEFORE_SHOW event for a long time, and too much code relies on that old
<a name="line84"></a>   * behavior to fix it now.
<a name="line85"></a>   */
<a name="line86"></a>  AFTER_SHOW: &#39;aftershow&#39;,
<a name="line87"></a>
<a name="line88"></a>  /**
<a name="line89"></a>   * Dispatched after a goog.ui.Container becomes invisible. Non-cancellable.
<a name="line90"></a>   */
<a name="line91"></a>  AFTER_HIDE: &#39;afterhide&#39;
<a name="line92"></a>};
<a name="line93"></a>
<a name="line94"></a>
<a name="line95"></a>/**
<a name="line96"></a> * Container orientation constants.
<a name="line97"></a> * @enum {string}
<a name="line98"></a> */
<a name="line99"></a>goog.ui.Container.Orientation = {
<a name="line100"></a>  HORIZONTAL: &#39;horizontal&#39;,
<a name="line101"></a>  VERTICAL: &#39;vertical&#39;
<a name="line102"></a>};
<a name="line103"></a>
<a name="line104"></a>
<a name="line105"></a>/**
<a name="line106"></a> * Allows an alternative element to be set to receive key events, otherwise
<a name="line107"></a> * defers to the renderer&#39;s element choice.
<a name="line108"></a> * @type {Element|undefined}
<a name="line109"></a> * @private
<a name="line110"></a> */
<a name="line111"></a>goog.ui.Container.prototype.keyEventTarget_ = null;
<a name="line112"></a>
<a name="line113"></a>
<a name="line114"></a>/**
<a name="line115"></a> * Keyboard event handler.
<a name="line116"></a> * @type {goog.events.KeyHandler?}
<a name="line117"></a> * @private
<a name="line118"></a> */
<a name="line119"></a>goog.ui.Container.prototype.keyHandler_ = null;
<a name="line120"></a>
<a name="line121"></a>
<a name="line122"></a>/**
<a name="line123"></a> * Renderer for the container.  Defaults to {@link goog.ui.ContainerRenderer}.
<a name="line124"></a> * @type {goog.ui.ContainerRenderer?}
<a name="line125"></a> * @private
<a name="line126"></a> */
<a name="line127"></a>goog.ui.Container.prototype.renderer_ = null;
<a name="line128"></a>
<a name="line129"></a>
<a name="line130"></a>/**
<a name="line131"></a> * Container orientation; determines layout and default keyboard navigation.
<a name="line132"></a> * @type {?goog.ui.Container.Orientation}
<a name="line133"></a> * @private
<a name="line134"></a> */
<a name="line135"></a>goog.ui.Container.prototype.orientation_ = null;
<a name="line136"></a>
<a name="line137"></a>
<a name="line138"></a>/**
<a name="line139"></a> * Whether the container is set to be visible.  Defaults to true.
<a name="line140"></a> * @type {boolean}
<a name="line141"></a> * @private
<a name="line142"></a> */
<a name="line143"></a>goog.ui.Container.prototype.visible_ = true;
<a name="line144"></a>
<a name="line145"></a>
<a name="line146"></a>/**
<a name="line147"></a> * Whether the container is enabled and reacting to keyboard and mouse events.
<a name="line148"></a> * Defaults to true.
<a name="line149"></a> * @type {boolean}
<a name="line150"></a> * @private
<a name="line151"></a> */
<a name="line152"></a>goog.ui.Container.prototype.enabled_ = true;
<a name="line153"></a>
<a name="line154"></a>
<a name="line155"></a>/**
<a name="line156"></a> * Whether the container supports keyboard focus.  Defaults to true.  Focusable
<a name="line157"></a> * containers have a {@code tabIndex} and can be navigated to via the keyboard.
<a name="line158"></a> * @type {boolean}
<a name="line159"></a> * @private
<a name="line160"></a> */
<a name="line161"></a>goog.ui.Container.prototype.focusable_ = true;
<a name="line162"></a>
<a name="line163"></a>
<a name="line164"></a>/**
<a name="line165"></a> * The 0-based index of the currently highlighted control in the container
<a name="line166"></a> * (-1 if none).
<a name="line167"></a> * @type {number}
<a name="line168"></a> * @private
<a name="line169"></a> */
<a name="line170"></a>goog.ui.Container.prototype.highlightedIndex_ = -1;
<a name="line171"></a>
<a name="line172"></a>
<a name="line173"></a>/**
<a name="line174"></a> * The currently open (expanded) control in the container (null if none).
<a name="line175"></a> * @type {goog.ui.Control?}
<a name="line176"></a> * @private
<a name="line177"></a> */
<a name="line178"></a>goog.ui.Container.prototype.openItem_ = null;
<a name="line179"></a>
<a name="line180"></a>
<a name="line181"></a>/**
<a name="line182"></a> * Whether the mouse button is held down.  Defaults to false.  This flag is set
<a name="line183"></a> * when the user mouses down over the container, and remains set until they
<a name="line184"></a> * release the mouse button.
<a name="line185"></a> * @type {boolean}
<a name="line186"></a> * @private
<a name="line187"></a> */
<a name="line188"></a>goog.ui.Container.prototype.mouseButtonPressed_ = false;
<a name="line189"></a>
<a name="line190"></a>
<a name="line191"></a>/**
<a name="line192"></a> * Whether focus of child components should be allowed.  Only effective if
<a name="line193"></a> * focusable_ is set to false.
<a name="line194"></a> * @type {boolean}
<a name="line195"></a> * @private
<a name="line196"></a> */
<a name="line197"></a>goog.ui.Container.prototype.allowFocusableChildren_ = false;
<a name="line198"></a>
<a name="line199"></a>
<a name="line200"></a>/**
<a name="line201"></a> * Whether highlighting a child component should also open it.
<a name="line202"></a> * @type {boolean}
<a name="line203"></a> * @private
<a name="line204"></a> */
<a name="line205"></a>goog.ui.Container.prototype.openFollowsHighlight_ = true;
<a name="line206"></a>
<a name="line207"></a>
<a name="line208"></a>/**
<a name="line209"></a> * Map of DOM IDs to child controls.  Each key is the DOM ID of a child
<a name="line210"></a> * control&#39;s root element; each value is a reference to the child control
<a name="line211"></a> * itself.  Used for looking up the child control corresponding to a DOM
<a name="line212"></a> * node in O(1) time.
<a name="line213"></a> * @type {Object}
<a name="line214"></a> * @private
<a name="line215"></a> */
<a name="line216"></a>goog.ui.Container.prototype.childElementIdMap_ = null;
<a name="line217"></a>
<a name="line218"></a>
<a name="line219"></a>// Event handler and renderer management.
<a name="line220"></a>
<a name="line221"></a>
<a name="line222"></a>/**
<a name="line223"></a> * Returns the DOM element on which the container is listening for keyboard
<a name="line224"></a> * events (null if none).
<a name="line225"></a> * @return {Element} Element on which the container is listening for key
<a name="line226"></a> *     events.
<a name="line227"></a> */
<a name="line228"></a>goog.ui.Container.prototype.getKeyEventTarget = function() {
<a name="line229"></a>  // Delegate to renderer, unless we&#39;ve set an explicit target.
<a name="line230"></a>  return this.keyEventTarget_ || this.renderer_.getKeyEventTarget(this);
<a name="line231"></a>};
<a name="line232"></a>
<a name="line233"></a>
<a name="line234"></a>/**
<a name="line235"></a> * Attaches an element on which to listen for key events.
<a name="line236"></a> * @param {Element|undefined} element The element to attach, or null/undefined
<a name="line237"></a> *     to attach to the default element.
<a name="line238"></a> */
<a name="line239"></a>goog.ui.Container.prototype.setKeyEventTarget = function(element) {
<a name="line240"></a>  if (this.focusable_) {
<a name="line241"></a>    var oldTarget = this.getKeyEventTarget();
<a name="line242"></a>    var inDocument = this.isInDocument();
<a name="line243"></a>
<a name="line244"></a>    this.keyEventTarget_ = element;
<a name="line245"></a>    var newTarget = this.getKeyEventTarget();
<a name="line246"></a>
<a name="line247"></a>    if (inDocument) {
<a name="line248"></a>      // Unlisten for events on the old key target.  Requires us to reset
<a name="line249"></a>      // key target state temporarily.
<a name="line250"></a>      this.keyEventTarget_ = oldTarget;
<a name="line251"></a>      this.enableFocusHandling_(false);
<a name="line252"></a>      this.keyEventTarget_ = element;
<a name="line253"></a>
<a name="line254"></a>      // Listen for events on the new key target.
<a name="line255"></a>      this.getKeyHandler().attach(newTarget);
<a name="line256"></a>      this.enableFocusHandling_(true);
<a name="line257"></a>    }
<a name="line258"></a>  } else {
<a name="line259"></a>    throw Error(&#39;Can\&#39;t set key event target for container &#39; +
<a name="line260"></a>        &#39;that doesn\&#39;t support keyboard focus!&#39;);
<a name="line261"></a>  }
<a name="line262"></a>};
<a name="line263"></a>
<a name="line264"></a>
<a name="line265"></a>/**
<a name="line266"></a> * Returns the keyboard event handler for this container, lazily created the
<a name="line267"></a> * first time this method is called.  The keyboard event handler listens for
<a name="line268"></a> * keyboard events on the container&#39;s key event target, as determined by its
<a name="line269"></a> * renderer.
<a name="line270"></a> * @return {goog.events.KeyHandler} Keyboard event handler for this container.
<a name="line271"></a> */
<a name="line272"></a>goog.ui.Container.prototype.getKeyHandler = function() {
<a name="line273"></a>  return this.keyHandler_ ||
<a name="line274"></a>      (this.keyHandler_ = new goog.events.KeyHandler(this.getKeyEventTarget()));
<a name="line275"></a>};
<a name="line276"></a>
<a name="line277"></a>
<a name="line278"></a>/**
<a name="line279"></a> * Returns the renderer used by this container to render itself or to decorate
<a name="line280"></a> * an existing element.
<a name="line281"></a> * @return {goog.ui.ContainerRenderer} Renderer used by the container.
<a name="line282"></a> */
<a name="line283"></a>goog.ui.Container.prototype.getRenderer = function() {
<a name="line284"></a>  return this.renderer_;
<a name="line285"></a>};
<a name="line286"></a>
<a name="line287"></a>
<a name="line288"></a>/**
<a name="line289"></a> * Registers the given renderer with the container.  Changing renderers after
<a name="line290"></a> * the container has already been rendered or decorated is an error.
<a name="line291"></a> * @param {goog.ui.ContainerRenderer} renderer Renderer used by the container.
<a name="line292"></a> */
<a name="line293"></a>goog.ui.Container.prototype.setRenderer = function(renderer) {
<a name="line294"></a>  if (this.getElement()) {
<a name="line295"></a>    // Too late.
<a name="line296"></a>    throw Error(goog.ui.Component.Error.ALREADY_RENDERED);
<a name="line297"></a>  }
<a name="line298"></a>
<a name="line299"></a>  this.renderer_ = renderer;
<a name="line300"></a>};
<a name="line301"></a>
<a name="line302"></a>
<a name="line303"></a>// Standard goog.ui.Component implementation.
<a name="line304"></a>
<a name="line305"></a>
<a name="line306"></a>/**
<a name="line307"></a> * Creates the container&#39;s DOM.
<a name="line308"></a> * @override
<a name="line309"></a> */
<a name="line310"></a>goog.ui.Container.prototype.createDom = function() {
<a name="line311"></a>  // Delegate to renderer.
<a name="line312"></a>  this.setElementInternal(this.renderer_.createDom(this));
<a name="line313"></a>};
<a name="line314"></a>
<a name="line315"></a>
<a name="line316"></a>/**
<a name="line317"></a> * Returns the DOM element into which child components are to be rendered,
<a name="line318"></a> * or null if the container itself hasn&#39;t been rendered yet.  Overrides
<a name="line319"></a> * {@link goog.ui.Component#getContentElement} by delegating to the renderer.
<a name="line320"></a> * @return {Element} Element to contain child elements (null if none).
<a name="line321"></a> * @override
<a name="line322"></a> */
<a name="line323"></a>goog.ui.Container.prototype.getContentElement = function() {
<a name="line324"></a>  // Delegate to renderer.
<a name="line325"></a>  return this.renderer_.getContentElement(this.getElement());
<a name="line326"></a>};
<a name="line327"></a>
<a name="line328"></a>
<a name="line329"></a>/**
<a name="line330"></a> * Returns true if the given element can be decorated by this container.
<a name="line331"></a> * Overrides {@link goog.ui.Component#canDecorate}.
<a name="line332"></a> * @param {Element} element Element to decorate.
<a name="line333"></a> * @return {boolean} True iff the element can be decorated.
<a name="line334"></a> * @override
<a name="line335"></a> */
<a name="line336"></a>goog.ui.Container.prototype.canDecorate = function(element) {
<a name="line337"></a>  // Delegate to renderer.
<a name="line338"></a>  return this.renderer_.canDecorate(element);
<a name="line339"></a>};
<a name="line340"></a>
<a name="line341"></a>
<a name="line342"></a>/**
<a name="line343"></a> * Decorates the given element with this container. Overrides {@link
<a name="line344"></a> * goog.ui.Component#decorateInternal}.  Considered protected.
<a name="line345"></a> * @param {Element} element Element to decorate.
<a name="line346"></a> * @override
<a name="line347"></a> */
<a name="line348"></a>goog.ui.Container.prototype.decorateInternal = function(element) {
<a name="line349"></a>  // Delegate to renderer.
<a name="line350"></a>  this.setElementInternal(this.renderer_.decorate(this, element));
<a name="line351"></a>  // Check whether the decorated element is explicitly styled to be invisible.
<a name="line352"></a>  if (element.style.display == &#39;none&#39;) {
<a name="line353"></a>    this.visible_ = false;
<a name="line354"></a>  }
<a name="line355"></a>};
<a name="line356"></a>
<a name="line357"></a>
<a name="line358"></a>/**
<a name="line359"></a> * Configures the container after its DOM has been rendered, and sets up event
<a name="line360"></a> * handling.  Overrides {@link goog.ui.Component#enterDocument}.
<a name="line361"></a> * @override
<a name="line362"></a> */
<a name="line363"></a>goog.ui.Container.prototype.enterDocument = function() {
<a name="line364"></a>  goog.ui.Container.superClass_.enterDocument.call(this);
<a name="line365"></a>
<a name="line366"></a>  this.forEachChild(function(child) {
<a name="line367"></a>    if (child.isInDocument()) {
<a name="line368"></a>      this.registerChildId_(child);
<a name="line369"></a>    }
<a name="line370"></a>  }, this);
<a name="line371"></a>
<a name="line372"></a>  var elem = this.getElement();
<a name="line373"></a>
<a name="line374"></a>  // Call the renderer&#39;s initializeDom method to initialize the container&#39;s DOM.
<a name="line375"></a>  this.renderer_.initializeDom(this);
<a name="line376"></a>
<a name="line377"></a>  // Initialize visibility (opt_force = true, so we don&#39;t dispatch events).
<a name="line378"></a>  this.setVisible(this.visible_, true);
<a name="line379"></a>
<a name="line380"></a>  // Handle events dispatched by child controls.
<a name="line381"></a>  this.getHandler().
<a name="line382"></a>      listen(this, goog.ui.Component.EventType.ENTER,
<a name="line383"></a>          this.handleEnterItem).
<a name="line384"></a>      listen(this, goog.ui.Component.EventType.HIGHLIGHT,
<a name="line385"></a>          this.handleHighlightItem).
<a name="line386"></a>      listen(this, goog.ui.Component.EventType.UNHIGHLIGHT,
<a name="line387"></a>          this.handleUnHighlightItem).
<a name="line388"></a>      listen(this, goog.ui.Component.EventType.OPEN, this.handleOpenItem).
<a name="line389"></a>      listen(this, goog.ui.Component.EventType.CLOSE, this.handleCloseItem).
<a name="line390"></a>
<a name="line391"></a>      // Handle mouse events.
<a name="line392"></a>      listen(elem, goog.events.EventType.MOUSEDOWN, this.handleMouseDown).
<a name="line393"></a>      listen(goog.dom.getOwnerDocument(elem), goog.events.EventType.MOUSEUP,
<a name="line394"></a>          this.handleDocumentMouseUp).
<a name="line395"></a>
<a name="line396"></a>      // Handle mouse events on behalf of controls in the container.
<a name="line397"></a>      listen(elem, [
<a name="line398"></a>        goog.events.EventType.MOUSEDOWN,
<a name="line399"></a>        goog.events.EventType.MOUSEUP,
<a name="line400"></a>        goog.events.EventType.MOUSEOVER,
<a name="line401"></a>        goog.events.EventType.MOUSEOUT,
<a name="line402"></a>        goog.events.EventType.CONTEXTMENU
<a name="line403"></a>      ], this.handleChildMouseEvents);
<a name="line404"></a>
<a name="line405"></a>  // If the container is focusable, set up keyboard event handling.
<a name="line406"></a>  if (this.isFocusable()) {
<a name="line407"></a>    this.enableFocusHandling_(true);
<a name="line408"></a>  }
<a name="line409"></a>};
<a name="line410"></a>
<a name="line411"></a>
<a name="line412"></a>/**
<a name="line413"></a> * Sets up listening for events applicable to focusable containers.
<a name="line414"></a> * @param {boolean} enable Whether to enable or disable focus handling.
<a name="line415"></a> * @private
<a name="line416"></a> */
<a name="line417"></a>goog.ui.Container.prototype.enableFocusHandling_ = function(enable) {
<a name="line418"></a>  var handler = this.getHandler();
<a name="line419"></a>  var keyTarget = this.getKeyEventTarget();
<a name="line420"></a>  if (enable) {
<a name="line421"></a>    handler.
<a name="line422"></a>        listen(keyTarget, goog.events.EventType.FOCUS, this.handleFocus).
<a name="line423"></a>        listen(keyTarget, goog.events.EventType.BLUR, this.handleBlur).
<a name="line424"></a>        listen(this.getKeyHandler(), goog.events.KeyHandler.EventType.KEY,
<a name="line425"></a>            this.handleKeyEvent);
<a name="line426"></a>  } else {
<a name="line427"></a>    handler.
<a name="line428"></a>        unlisten(keyTarget, goog.events.EventType.FOCUS, this.handleFocus).
<a name="line429"></a>        unlisten(keyTarget, goog.events.EventType.BLUR, this.handleBlur).
<a name="line430"></a>        unlisten(this.getKeyHandler(), goog.events.KeyHandler.EventType.KEY,
<a name="line431"></a>            this.handleKeyEvent);
<a name="line432"></a>  }
<a name="line433"></a>};
<a name="line434"></a>
<a name="line435"></a>
<a name="line436"></a>/**
<a name="line437"></a> * Cleans up the container before its DOM is removed from the document, and
<a name="line438"></a> * removes event handlers.  Overrides {@link goog.ui.Component#exitDocument}.
<a name="line439"></a> * @override
<a name="line440"></a> */
<a name="line441"></a>goog.ui.Container.prototype.exitDocument = function() {
<a name="line442"></a>  // {@link #setHighlightedIndex} has to be called before
<a name="line443"></a>  // {@link goog.ui.Component#exitDocument}, otherwise it has no effect.
<a name="line444"></a>  this.setHighlightedIndex(-1);
<a name="line445"></a>
<a name="line446"></a>  if (this.openItem_) {
<a name="line447"></a>    this.openItem_.setOpen(false);
<a name="line448"></a>  }
<a name="line449"></a>
<a name="line450"></a>  this.mouseButtonPressed_ = false;
<a name="line451"></a>
<a name="line452"></a>  goog.ui.Container.superClass_.exitDocument.call(this);
<a name="line453"></a>};
<a name="line454"></a>
<a name="line455"></a>
<a name="line456"></a>/** @override */
<a name="line457"></a>goog.ui.Container.prototype.disposeInternal = function() {
<a name="line458"></a>  goog.ui.Container.superClass_.disposeInternal.call(this);
<a name="line459"></a>
<a name="line460"></a>  if (this.keyHandler_) {
<a name="line461"></a>    this.keyHandler_.dispose();
<a name="line462"></a>    this.keyHandler_ = null;
<a name="line463"></a>  }
<a name="line464"></a>
<a name="line465"></a>  this.keyEventTarget_ = null;
<a name="line466"></a>  this.childElementIdMap_ = null;
<a name="line467"></a>  this.openItem_ = null;
<a name="line468"></a>  this.renderer_ = null;
<a name="line469"></a>};
<a name="line470"></a>
<a name="line471"></a>
<a name="line472"></a>// Default event handlers.
<a name="line473"></a>
<a name="line474"></a>
<a name="line475"></a>/**
<a name="line476"></a> * Handles ENTER events raised by child controls when they are navigated to.
<a name="line477"></a> * @param {goog.events.Event} e ENTER event to handle.
<a name="line478"></a> * @return {boolean} Whether to prevent handleMouseOver from handling
<a name="line479"></a> *    the event.
<a name="line480"></a> */
<a name="line481"></a>goog.ui.Container.prototype.handleEnterItem = function(e) {
<a name="line482"></a>  // Allow the Control to highlight itself.
<a name="line483"></a>  return true;
<a name="line484"></a>};
<a name="line485"></a>
<a name="line486"></a>
<a name="line487"></a>/**
<a name="line488"></a> * Handles HIGHLIGHT events dispatched by items in the container when
<a name="line489"></a> * they are highlighted.
<a name="line490"></a> * @param {goog.events.Event} e Highlight event to handle.
<a name="line491"></a> */
<a name="line492"></a>goog.ui.Container.prototype.handleHighlightItem = function(e) {
<a name="line493"></a>  var index = this.indexOfChild(/** @type {goog.ui.Control} */ (e.target));
<a name="line494"></a>  if (index &gt; -1 &amp;&amp; index != this.highlightedIndex_) {
<a name="line495"></a>    var item = this.getHighlighted();
<a name="line496"></a>    if (item) {
<a name="line497"></a>      // Un-highlight previously highlighted item.
<a name="line498"></a>      item.setHighlighted(false);
<a name="line499"></a>    }
<a name="line500"></a>
<a name="line501"></a>    this.highlightedIndex_ = index;
<a name="line502"></a>    item = this.getHighlighted();
<a name="line503"></a>
<a name="line504"></a>    if (this.isMouseButtonPressed()) {
<a name="line505"></a>      // Activate item when mouse button is pressed, to allow MacOS-style
<a name="line506"></a>      // dragging to choose menu items.  Although this should only truly
<a name="line507"></a>      // happen if the highlight is due to mouse movements, there is little
<a name="line508"></a>      // harm in doing it for keyboard or programmatic highlights.
<a name="line509"></a>      item.setActive(true);
<a name="line510"></a>    }
<a name="line511"></a>
<a name="line512"></a>    // Update open item if open item needs follow highlight.
<a name="line513"></a>    if (this.openFollowsHighlight_ &amp;&amp;
<a name="line514"></a>        this.openItem_ &amp;&amp; item != this.openItem_) {
<a name="line515"></a>      if (item.isSupportedState(goog.ui.Component.State.OPENED)) {
<a name="line516"></a>        item.setOpen(true);
<a name="line517"></a>      } else {
<a name="line518"></a>        this.openItem_.setOpen(false);
<a name="line519"></a>      }
<a name="line520"></a>    }
<a name="line521"></a>  }
<a name="line522"></a>
<a name="line523"></a>  var element = this.getElement();
<a name="line524"></a>  goog.asserts.assert(element,
<a name="line525"></a>      &#39;The DOM element for the container cannot be null.&#39;);
<a name="line526"></a>  if (e.target.getElement() != null) {
<a name="line527"></a>    goog.a11y.aria.setState(element,
<a name="line528"></a>        goog.a11y.aria.State.ACTIVEDESCENDANT,
<a name="line529"></a>        e.target.getElement().id);
<a name="line530"></a>  }
<a name="line531"></a>};
<a name="line532"></a>
<a name="line533"></a>
<a name="line534"></a>/**
<a name="line535"></a> * Handles UNHIGHLIGHT events dispatched by items in the container when
<a name="line536"></a> * they are unhighlighted.
<a name="line537"></a> * @param {goog.events.Event} e Unhighlight event to handle.
<a name="line538"></a> */
<a name="line539"></a>goog.ui.Container.prototype.handleUnHighlightItem = function(e) {
<a name="line540"></a>  if (e.target == this.getHighlighted()) {
<a name="line541"></a>    this.highlightedIndex_ = -1;
<a name="line542"></a>  }
<a name="line543"></a>  var element = this.getElement();
<a name="line544"></a>  goog.asserts.assert(element,
<a name="line545"></a>      &#39;The DOM element for the container cannot be null.&#39;);
<a name="line546"></a>  // Setting certain ARIA attributes to empty strings is problematic.
<a name="line547"></a>  // Just remove the attribute instead.
<a name="line548"></a>  goog.a11y.aria.removeState(element, goog.a11y.aria.State.ACTIVEDESCENDANT);
<a name="line549"></a>};
<a name="line550"></a>
<a name="line551"></a>
<a name="line552"></a>/**
<a name="line553"></a> * Handles OPEN events dispatched by items in the container when they are
<a name="line554"></a> * opened.
<a name="line555"></a> * @param {goog.events.Event} e Open event to handle.
<a name="line556"></a> */
<a name="line557"></a>goog.ui.Container.prototype.handleOpenItem = function(e) {
<a name="line558"></a>  var item = /** @type {goog.ui.Control} */ (e.target);
<a name="line559"></a>  if (item &amp;&amp; item != this.openItem_ &amp;&amp; item.getParent() == this) {
<a name="line560"></a>    if (this.openItem_) {
<a name="line561"></a>      this.openItem_.setOpen(false);
<a name="line562"></a>    }
<a name="line563"></a>    this.openItem_ = item;
<a name="line564"></a>  }
<a name="line565"></a>};
<a name="line566"></a>
<a name="line567"></a>
<a name="line568"></a>/**
<a name="line569"></a> * Handles CLOSE events dispatched by items in the container when they are
<a name="line570"></a> * closed.
<a name="line571"></a> * @param {goog.events.Event} e Close event to handle.
<a name="line572"></a> */
<a name="line573"></a>goog.ui.Container.prototype.handleCloseItem = function(e) {
<a name="line574"></a>  if (e.target == this.openItem_) {
<a name="line575"></a>    this.openItem_ = null;
<a name="line576"></a>  }
<a name="line577"></a>};
<a name="line578"></a>
<a name="line579"></a>
<a name="line580"></a>/**
<a name="line581"></a> * Handles mousedown events over the container.  The default implementation
<a name="line582"></a> * sets the &quot;mouse button pressed&quot; flag and, if the container is focusable,
<a name="line583"></a> * grabs keyboard focus.
<a name="line584"></a> * @param {goog.events.BrowserEvent} e Mousedown event to handle.
<a name="line585"></a> */
<a name="line586"></a>goog.ui.Container.prototype.handleMouseDown = function(e) {
<a name="line587"></a>  if (this.enabled_) {
<a name="line588"></a>    this.setMouseButtonPressed(true);
<a name="line589"></a>  }
<a name="line590"></a>
<a name="line591"></a>  var keyTarget = this.getKeyEventTarget();
<a name="line592"></a>  if (keyTarget &amp;&amp; goog.dom.isFocusableTabIndex(keyTarget)) {
<a name="line593"></a>    // The container is configured to receive keyboard focus.
<a name="line594"></a>    keyTarget.focus();
<a name="line595"></a>  } else {
<a name="line596"></a>    // The control isn&#39;t configured to receive keyboard focus; prevent it
<a name="line597"></a>    // from stealing focus or destroying the selection.
<a name="line598"></a>    e.preventDefault();
<a name="line599"></a>  }
<a name="line600"></a>};
<a name="line601"></a>
<a name="line602"></a>
<a name="line603"></a>/**
<a name="line604"></a> * Handles mouseup events over the document.  The default implementation
<a name="line605"></a> * clears the &quot;mouse button pressed&quot; flag.
<a name="line606"></a> * @param {goog.events.BrowserEvent} e Mouseup event to handle.
<a name="line607"></a> */
<a name="line608"></a>goog.ui.Container.prototype.handleDocumentMouseUp = function(e) {
<a name="line609"></a>  this.setMouseButtonPressed(false);
<a name="line610"></a>};
<a name="line611"></a>
<a name="line612"></a>
<a name="line613"></a>/**
<a name="line614"></a> * Handles mouse events originating from nodes belonging to the controls hosted
<a name="line615"></a> * in the container.  Locates the child control based on the DOM node that
<a name="line616"></a> * dispatched the event, and forwards the event to the control for handling.
<a name="line617"></a> * @param {goog.events.BrowserEvent} e Mouse event to handle.
<a name="line618"></a> */
<a name="line619"></a>goog.ui.Container.prototype.handleChildMouseEvents = function(e) {
<a name="line620"></a>  var control = this.getOwnerControl(/** @type {Node} */ (e.target));
<a name="line621"></a>  if (control) {
<a name="line622"></a>    // Child control identified; forward the event.
<a name="line623"></a>    switch (e.type) {
<a name="line624"></a>      case goog.events.EventType.MOUSEDOWN:
<a name="line625"></a>        control.handleMouseDown(e);
<a name="line626"></a>        break;
<a name="line627"></a>      case goog.events.EventType.MOUSEUP:
<a name="line628"></a>        control.handleMouseUp(e);
<a name="line629"></a>        break;
<a name="line630"></a>      case goog.events.EventType.MOUSEOVER:
<a name="line631"></a>        control.handleMouseOver(e);
<a name="line632"></a>        break;
<a name="line633"></a>      case goog.events.EventType.MOUSEOUT:
<a name="line634"></a>        control.handleMouseOut(e);
<a name="line635"></a>        break;
<a name="line636"></a>      case goog.events.EventType.CONTEXTMENU:
<a name="line637"></a>        control.handleContextMenu(e);
<a name="line638"></a>        break;
<a name="line639"></a>    }
<a name="line640"></a>  }
<a name="line641"></a>};
<a name="line642"></a>
<a name="line643"></a>
<a name="line644"></a>/**
<a name="line645"></a> * Returns the child control that owns the given DOM node, or null if no such
<a name="line646"></a> * control is found.
<a name="line647"></a> * @param {Node} node DOM node whose owner is to be returned.
<a name="line648"></a> * @return {goog.ui.Control?} Control hosted in the container to which the node
<a name="line649"></a> *     belongs (if found).
<a name="line650"></a> * @protected
<a name="line651"></a> */
<a name="line652"></a>goog.ui.Container.prototype.getOwnerControl = function(node) {
<a name="line653"></a>  // Ensure that this container actually has child controls before
<a name="line654"></a>  // looking up the owner.
<a name="line655"></a>  if (this.childElementIdMap_) {
<a name="line656"></a>    var elem = this.getElement();
<a name="line657"></a>    // See http://b/2964418 . IE9 appears to evaluate &#39;!=&#39; incorrectly, so
<a name="line658"></a>    // using &#39;!==&#39; instead.
<a name="line659"></a>    // TODO(user): Possibly revert this change if/when IE9 fixes the issue.
<a name="line660"></a>    while (node &amp;&amp; node !== elem) {
<a name="line661"></a>      var id = node.id;
<a name="line662"></a>      if (id in this.childElementIdMap_) {
<a name="line663"></a>        return this.childElementIdMap_[id];
<a name="line664"></a>      }
<a name="line665"></a>      node = node.parentNode;
<a name="line666"></a>    }
<a name="line667"></a>  }
<a name="line668"></a>  return null;
<a name="line669"></a>};
<a name="line670"></a>
<a name="line671"></a>
<a name="line672"></a>/**
<a name="line673"></a> * Handles focus events raised when the container&#39;s key event target receives
<a name="line674"></a> * keyboard focus.
<a name="line675"></a> * @param {goog.events.BrowserEvent} e Focus event to handle.
<a name="line676"></a> */
<a name="line677"></a>goog.ui.Container.prototype.handleFocus = function(e) {
<a name="line678"></a>  // No-op in the base class.
<a name="line679"></a>};
<a name="line680"></a>
<a name="line681"></a>
<a name="line682"></a>/**
<a name="line683"></a> * Handles blur events raised when the container&#39;s key event target loses
<a name="line684"></a> * keyboard focus.  The default implementation clears the highlight index.
<a name="line685"></a> * @param {goog.events.BrowserEvent} e Blur event to handle.
<a name="line686"></a> */
<a name="line687"></a>goog.ui.Container.prototype.handleBlur = function(e) {
<a name="line688"></a>  this.setHighlightedIndex(-1);
<a name="line689"></a>  this.setMouseButtonPressed(false);
<a name="line690"></a>  // If the container loses focus, and one of its children is open, close it.
<a name="line691"></a>  if (this.openItem_) {
<a name="line692"></a>    this.openItem_.setOpen(false);
<a name="line693"></a>  }
<a name="line694"></a>};
<a name="line695"></a>
<a name="line696"></a>
<a name="line697"></a>/**
<a name="line698"></a> * Attempts to handle a keyboard event, if the control is enabled, by calling
<a name="line699"></a> * {@link handleKeyEventInternal}.  Considered protected; should only be used
<a name="line700"></a> * within this package and by subclasses.
<a name="line701"></a> * @param {goog.events.KeyEvent} e Key event to handle.
<a name="line702"></a> * @return {boolean} Whether the key event was handled.
<a name="line703"></a> */
<a name="line704"></a>goog.ui.Container.prototype.handleKeyEvent = function(e) {
<a name="line705"></a>  if (this.isEnabled() &amp;&amp; this.isVisible() &amp;&amp;
<a name="line706"></a>      (this.getChildCount() != 0 || this.keyEventTarget_) &amp;&amp;
<a name="line707"></a>      this.handleKeyEventInternal(e)) {
<a name="line708"></a>    e.preventDefault();
<a name="line709"></a>    e.stopPropagation();
<a name="line710"></a>    return true;
<a name="line711"></a>  }
<a name="line712"></a>  return false;
<a name="line713"></a>};
<a name="line714"></a>
<a name="line715"></a>
<a name="line716"></a>/**
<a name="line717"></a> * Attempts to handle a keyboard event; returns true if the event was handled,
<a name="line718"></a> * false otherwise.  If the container is enabled, and a child is highlighted,
<a name="line719"></a> * calls the child control&#39;s {@code handleKeyEvent} method to give the control
<a name="line720"></a> * a chance to handle the event first.
<a name="line721"></a> * @param {goog.events.KeyEvent} e Key event to handle.
<a name="line722"></a> * @return {boolean} Whether the event was handled by the container (or one of
<a name="line723"></a> *     its children).
<a name="line724"></a> */
<a name="line725"></a>goog.ui.Container.prototype.handleKeyEventInternal = function(e) {
<a name="line726"></a>  // Give the highlighted control the chance to handle the key event.
<a name="line727"></a>  var highlighted = this.getHighlighted();
<a name="line728"></a>  if (highlighted &amp;&amp; typeof highlighted.handleKeyEvent == &#39;function&#39; &amp;&amp;
<a name="line729"></a>      highlighted.handleKeyEvent(e)) {
<a name="line730"></a>    return true;
<a name="line731"></a>  }
<a name="line732"></a>
<a name="line733"></a>  // Give the open control the chance to handle the key event.
<a name="line734"></a>  if (this.openItem_ &amp;&amp; this.openItem_ != highlighted &amp;&amp;
<a name="line735"></a>      typeof this.openItem_.handleKeyEvent == &#39;function&#39; &amp;&amp;
<a name="line736"></a>      this.openItem_.handleKeyEvent(e)) {
<a name="line737"></a>    return true;
<a name="line738"></a>  }
<a name="line739"></a>
<a name="line740"></a>  // Do not handle the key event if any modifier key is pressed.
<a name="line741"></a>  if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) {
<a name="line742"></a>    return false;
<a name="line743"></a>  }
<a name="line744"></a>
<a name="line745"></a>  // Either nothing is highlighted, or the highlighted control didn&#39;t handle
<a name="line746"></a>  // the key event, so attempt to handle it here.
<a name="line747"></a>  switch (e.keyCode) {
<a name="line748"></a>    case goog.events.KeyCodes.ESC:
<a name="line749"></a>      if (this.isFocusable()) {
<a name="line750"></a>        this.getKeyEventTarget().blur();
<a name="line751"></a>      } else {
<a name="line752"></a>        return false;
<a name="line753"></a>      }
<a name="line754"></a>      break;
<a name="line755"></a>
<a name="line756"></a>    case goog.events.KeyCodes.HOME:
<a name="line757"></a>      this.highlightFirst();
<a name="line758"></a>      break;
<a name="line759"></a>
<a name="line760"></a>    case goog.events.KeyCodes.END:
<a name="line761"></a>      this.highlightLast();
<a name="line762"></a>      break;
<a name="line763"></a>
<a name="line764"></a>    case goog.events.KeyCodes.UP:
<a name="line765"></a>      if (this.orientation_ == goog.ui.Container.Orientation.VERTICAL) {
<a name="line766"></a>        this.highlightPrevious();
<a name="line767"></a>      } else {
<a name="line768"></a>        return false;
<a name="line769"></a>      }
<a name="line770"></a>      break;
<a name="line771"></a>
<a name="line772"></a>    case goog.events.KeyCodes.LEFT:
<a name="line773"></a>      if (this.orientation_ == goog.ui.Container.Orientation.HORIZONTAL) {
<a name="line774"></a>        if (this.isRightToLeft()) {
<a name="line775"></a>          this.highlightNext();
<a name="line776"></a>        } else {
<a name="line777"></a>          this.highlightPrevious();
<a name="line778"></a>        }
<a name="line779"></a>      } else {
<a name="line780"></a>        return false;
<a name="line781"></a>      }
<a name="line782"></a>      break;
<a name="line783"></a>
<a name="line784"></a>    case goog.events.KeyCodes.DOWN:
<a name="line785"></a>      if (this.orientation_ == goog.ui.Container.Orientation.VERTICAL) {
<a name="line786"></a>        this.highlightNext();
<a name="line787"></a>      } else {
<a name="line788"></a>        return false;
<a name="line789"></a>      }
<a name="line790"></a>      break;
<a name="line791"></a>
<a name="line792"></a>    case goog.events.KeyCodes.RIGHT:
<a name="line793"></a>      if (this.orientation_ == goog.ui.Container.Orientation.HORIZONTAL) {
<a name="line794"></a>        if (this.isRightToLeft()) {
<a name="line795"></a>          this.highlightPrevious();
<a name="line796"></a>        } else {
<a name="line797"></a>          this.highlightNext();
<a name="line798"></a>        }
<a name="line799"></a>      } else {
<a name="line800"></a>        return false;
<a name="line801"></a>      }
<a name="line802"></a>      break;
<a name="line803"></a>
<a name="line804"></a>    default:
<a name="line805"></a>      return false;
<a name="line806"></a>  }
<a name="line807"></a>
<a name="line808"></a>  return true;
<a name="line809"></a>};
<a name="line810"></a>
<a name="line811"></a>
<a name="line812"></a>// Child component management.
<a name="line813"></a>
<a name="line814"></a>
<a name="line815"></a>/**
<a name="line816"></a> * Creates a DOM ID for the child control and registers it to an internal
<a name="line817"></a> * hash table to be able to find it fast by id.
<a name="line818"></a> * @param {goog.ui.Component} child The child control. Its root element has
<a name="line819"></a> *     to be created yet.
<a name="line820"></a> * @private
<a name="line821"></a> */
<a name="line822"></a>goog.ui.Container.prototype.registerChildId_ = function(child) {
<a name="line823"></a>  // Map the DOM ID of the control&#39;s root element to the control itself.
<a name="line824"></a>  var childElem = child.getElement();
<a name="line825"></a>
<a name="line826"></a>  // If the control&#39;s root element doesn&#39;t have a DOM ID assign one.
<a name="line827"></a>  var id = childElem.id || (childElem.id = child.getId());
<a name="line828"></a>
<a name="line829"></a>  // Lazily create the child element ID map on first use.
<a name="line830"></a>  if (!this.childElementIdMap_) {
<a name="line831"></a>    this.childElementIdMap_ = {};
<a name="line832"></a>  }
<a name="line833"></a>  this.childElementIdMap_[id] = child;
<a name="line834"></a>};
<a name="line835"></a>
<a name="line836"></a>
<a name="line837"></a>/**
<a name="line838"></a> * Adds the specified control as the last child of this container.  See
<a name="line839"></a> * {@link goog.ui.Container#addChildAt} for detailed semantics.
<a name="line840"></a> * @param {goog.ui.Component} child The new child control.
<a name="line841"></a> * @param {boolean=} opt_render Whether the new child should be rendered
<a name="line842"></a> *     immediately after being added (defaults to false).
<a name="line843"></a> * @override
<a name="line844"></a> */
<a name="line845"></a>goog.ui.Container.prototype.addChild = function(child, opt_render) {
<a name="line846"></a>  goog.asserts.assertInstanceof(child, goog.ui.Control,
<a name="line847"></a>      &#39;The child of a container must be a control&#39;);
<a name="line848"></a>  goog.ui.Container.superClass_.addChild.call(this, child, opt_render);
<a name="line849"></a>};
<a name="line850"></a>
<a name="line851"></a>
<a name="line852"></a>/**
<a name="line853"></a> * Overrides {@link goog.ui.Container#getChild} to make it clear that it
<a name="line854"></a> * only returns {@link goog.ui.Control}s.
<a name="line855"></a> * @param {string} id Child component ID.
<a name="line856"></a> * @return {goog.ui.Control} The child with the given ID; null if none.
<a name="line857"></a> * @override
<a name="line858"></a> */
<a name="line859"></a>goog.ui.Container.prototype.getChild;
<a name="line860"></a>
<a name="line861"></a>
<a name="line862"></a>/**
<a name="line863"></a> * Overrides {@link goog.ui.Container#getChildAt} to make it clear that it
<a name="line864"></a> * only returns {@link goog.ui.Control}s.
<a name="line865"></a> * @param {number} index 0-based index.
<a name="line866"></a> * @return {goog.ui.Control} The child with the given ID; null if none.
<a name="line867"></a> * @override
<a name="line868"></a> */
<a name="line869"></a>goog.ui.Container.prototype.getChildAt;
<a name="line870"></a>
<a name="line871"></a>
<a name="line872"></a>/**
<a name="line873"></a> * Adds the control as a child of this container at the given 0-based index.
<a name="line874"></a> * Overrides {@link goog.ui.Component#addChildAt} by also updating the
<a name="line875"></a> * container&#39;s highlight index.  Since {@link goog.ui.Component#addChild} uses
<a name="line876"></a> * {@link #addChildAt} internally, we only need to override this method.
<a name="line877"></a> * @param {goog.ui.Component} control New child.
<a name="line878"></a> * @param {number} index Index at which the new child is to be added.
<a name="line879"></a> * @param {boolean=} opt_render Whether the new child should be rendered
<a name="line880"></a> *     immediately after being added (defaults to false).
<a name="line881"></a> * @override
<a name="line882"></a> */
<a name="line883"></a>goog.ui.Container.prototype.addChildAt = function(control, index, opt_render) {
<a name="line884"></a>  // Make sure the child control dispatches HIGHLIGHT, UNHIGHLIGHT, OPEN, and
<a name="line885"></a>  // CLOSE events, and that it doesn&#39;t steal keyboard focus.
<a name="line886"></a>  control.setDispatchTransitionEvents(goog.ui.Component.State.HOVER, true);
<a name="line887"></a>  control.setDispatchTransitionEvents(goog.ui.Component.State.OPENED, true);
<a name="line888"></a>  if (this.isFocusable() || !this.isFocusableChildrenAllowed()) {
<a name="line889"></a>    control.setSupportedState(goog.ui.Component.State.FOCUSED, false);
<a name="line890"></a>  }
<a name="line891"></a>
<a name="line892"></a>  // Disable mouse event handling by child controls.
<a name="line893"></a>  control.setHandleMouseEvents(false);
<a name="line894"></a>
<a name="line895"></a>  // Let the superclass implementation do the work.
<a name="line896"></a>  goog.ui.Container.superClass_.addChildAt.call(this, control, index,
<a name="line897"></a>      opt_render);
<a name="line898"></a>
<a name="line899"></a>  if (control.isInDocument() &amp;&amp; this.isInDocument()) {
<a name="line900"></a>    this.registerChildId_(control);
<a name="line901"></a>  }
<a name="line902"></a>
<a name="line903"></a>  // Update the highlight index, if needed.
<a name="line904"></a>  if (index &lt;= this.highlightedIndex_) {
<a name="line905"></a>    this.highlightedIndex_++;
<a name="line906"></a>  }
<a name="line907"></a>};
<a name="line908"></a>
<a name="line909"></a>
<a name="line910"></a>/**
<a name="line911"></a> * Removes a child control.  Overrides {@link goog.ui.Component#removeChild} by
<a name="line912"></a> * updating the highlight index.  Since {@link goog.ui.Component#removeChildAt}
<a name="line913"></a> * uses {@link #removeChild} internally, we only need to override this method.
<a name="line914"></a> * @param {string|goog.ui.Component} control The ID of the child to remove, or
<a name="line915"></a> *     the control itself.
<a name="line916"></a> * @param {boolean=} opt_unrender Whether to call {@code exitDocument} on the
<a name="line917"></a> *     removed control, and detach its DOM from the document (defaults to
<a name="line918"></a> *     false).
<a name="line919"></a> * @return {goog.ui.Control} The removed control, if any.
<a name="line920"></a> * @override
<a name="line921"></a> */
<a name="line922"></a>goog.ui.Container.prototype.removeChild = function(control, opt_unrender) {
<a name="line923"></a>  control = goog.isString(control) ? this.getChild(control) : control;
<a name="line924"></a>
<a name="line925"></a>  if (control) {
<a name="line926"></a>    var index = this.indexOfChild(control);
<a name="line927"></a>    if (index != -1) {
<a name="line928"></a>      if (index == this.highlightedIndex_) {
<a name="line929"></a>        control.setHighlighted(false);
<a name="line930"></a>        this.highlightedIndex_ = -1;
<a name="line931"></a>      } else if (index &lt; this.highlightedIndex_) {
<a name="line932"></a>        this.highlightedIndex_--;
<a name="line933"></a>      }
<a name="line934"></a>    }
<a name="line935"></a>
<a name="line936"></a>    // Remove the mapping from the child element ID map.
<a name="line937"></a>    var childElem = control.getElement();
<a name="line938"></a>    if (childElem &amp;&amp; childElem.id &amp;&amp; this.childElementIdMap_) {
<a name="line939"></a>      goog.object.remove(this.childElementIdMap_, childElem.id);
<a name="line940"></a>    }
<a name="line941"></a>  }
<a name="line942"></a>
<a name="line943"></a>  control = /** @type {goog.ui.Control} */ (
<a name="line944"></a>      goog.ui.Container.superClass_.removeChild.call(this, control,
<a name="line945"></a>          opt_unrender));
<a name="line946"></a>
<a name="line947"></a>  // Re-enable mouse event handling (in case the control is reused elsewhere).
<a name="line948"></a>  control.setHandleMouseEvents(true);
<a name="line949"></a>
<a name="line950"></a>  return control;
<a name="line951"></a>};
<a name="line952"></a>
<a name="line953"></a>
<a name="line954"></a>// Container state management.
<a name="line955"></a>
<a name="line956"></a>
<a name="line957"></a>/**
<a name="line958"></a> * Returns the container&#39;s orientation.
<a name="line959"></a> * @return {?goog.ui.Container.Orientation} Container orientation.
<a name="line960"></a> */
<a name="line961"></a>goog.ui.Container.prototype.getOrientation = function() {
<a name="line962"></a>  return this.orientation_;
<a name="line963"></a>};
<a name="line964"></a>
<a name="line965"></a>
<a name="line966"></a>/**
<a name="line967"></a> * Sets the container&#39;s orientation.
<a name="line968"></a> * @param {goog.ui.Container.Orientation} orientation Container orientation.
<a name="line969"></a> */
<a name="line970"></a>// TODO(attila): Do we need to support containers with dynamic orientation?
<a name="line971"></a>goog.ui.Container.prototype.setOrientation = function(orientation) {
<a name="line972"></a>  if (this.getElement()) {
<a name="line973"></a>    // Too late.
<a name="line974"></a>    throw Error(goog.ui.Component.Error.ALREADY_RENDERED);
<a name="line975"></a>  }
<a name="line976"></a>
<a name="line977"></a>  this.orientation_ = orientation;
<a name="line978"></a>};
<a name="line979"></a>
<a name="line980"></a>
<a name="line981"></a>/**
<a name="line982"></a> * Returns true if the container&#39;s visibility is set to visible, false if
<a name="line983"></a> * it is set to hidden.  A container that is set to hidden is guaranteed
<a name="line984"></a> * to be hidden from the user, but the reverse isn&#39;t necessarily true.
<a name="line985"></a> * A container may be set to visible but can otherwise be obscured by another
<a name="line986"></a> * element, rendered off-screen, or hidden using direct CSS manipulation.
<a name="line987"></a> * @return {boolean} Whether the container is set to be visible.
<a name="line988"></a> */
<a name="line989"></a>goog.ui.Container.prototype.isVisible = function() {
<a name="line990"></a>  return this.visible_;
<a name="line991"></a>};
<a name="line992"></a>
<a name="line993"></a>
<a name="line994"></a>/**
<a name="line995"></a> * Shows or hides the container.  Does nothing if the container already has
<a name="line996"></a> * the requested visibility.  Otherwise, dispatches a SHOW or HIDE event as
<a name="line997"></a> * appropriate, giving listeners a chance to prevent the visibility change.
<a name="line998"></a> * @param {boolean} visible Whether to show or hide the container.
<a name="line999"></a> * @param {boolean=} opt_force If true, doesn&#39;t check whether the container
<a name="line1000"></a> *     already has the requested visibility, and doesn&#39;t dispatch any events.
<a name="line1001"></a> * @return {boolean} Whether the visibility was changed.
<a name="line1002"></a> */
<a name="line1003"></a>goog.ui.Container.prototype.setVisible = function(visible, opt_force) {
<a name="line1004"></a>  if (opt_force || (this.visible_ != visible &amp;&amp; this.dispatchEvent(visible ?
<a name="line1005"></a>      goog.ui.Component.EventType.SHOW : goog.ui.Component.EventType.HIDE))) {
<a name="line1006"></a>    this.visible_ = visible;
<a name="line1007"></a>
<a name="line1008"></a>    var elem = this.getElement();
<a name="line1009"></a>    if (elem) {
<a name="line1010"></a>      goog.style.setElementShown(elem, visible);
<a name="line1011"></a>      if (this.isFocusable()) {
<a name="line1012"></a>        // Enable keyboard access only for enabled &amp; visible containers.
<a name="line1013"></a>        this.renderer_.enableTabIndex(this.getKeyEventTarget(),
<a name="line1014"></a>            this.enabled_ &amp;&amp; this.visible_);
<a name="line1015"></a>      }
<a name="line1016"></a>      if (!opt_force) {
<a name="line1017"></a>        this.dispatchEvent(this.visible_ ?
<a name="line1018"></a>            goog.ui.Container.EventType.AFTER_SHOW :
<a name="line1019"></a>            goog.ui.Container.EventType.AFTER_HIDE);
<a name="line1020"></a>      }
<a name="line1021"></a>    }
<a name="line1022"></a>
<a name="line1023"></a>    return true;
<a name="line1024"></a>  }
<a name="line1025"></a>
<a name="line1026"></a>  return false;
<a name="line1027"></a>};
<a name="line1028"></a>
<a name="line1029"></a>
<a name="line1030"></a>/**
<a name="line1031"></a> * Returns true if the container is enabled, false otherwise.
<a name="line1032"></a> * @return {boolean} Whether the container is enabled.
<a name="line1033"></a> */
<a name="line1034"></a>goog.ui.Container.prototype.isEnabled = function() {
<a name="line1035"></a>  return this.enabled_;
<a name="line1036"></a>};
<a name="line1037"></a>
<a name="line1038"></a>
<a name="line1039"></a>/**
<a name="line1040"></a> * Enables/disables the container based on the {@code enable} argument.
<a name="line1041"></a> * Dispatches an {@code ENABLED} or {@code DISABLED} event prior to changing
<a name="line1042"></a> * the container&#39;s state, which may be caught and canceled to prevent the
<a name="line1043"></a> * container from changing state.  Also enables/disables child controls.
<a name="line1044"></a> * @param {boolean} enable Whether to enable or disable the container.
<a name="line1045"></a> */
<a name="line1046"></a>goog.ui.Container.prototype.setEnabled = function(enable) {
<a name="line1047"></a>  if (this.enabled_ != enable &amp;&amp; this.dispatchEvent(enable ?
<a name="line1048"></a>      goog.ui.Component.EventType.ENABLE :
<a name="line1049"></a>      goog.ui.Component.EventType.DISABLE)) {
<a name="line1050"></a>    if (enable) {
<a name="line1051"></a>      // Flag the container as enabled first, then update children.  This is
<a name="line1052"></a>      // because controls can&#39;t be enabled if their parent is disabled.
<a name="line1053"></a>      this.enabled_ = true;
<a name="line1054"></a>      this.forEachChild(function(child) {
<a name="line1055"></a>        // Enable child control unless it is flagged.
<a name="line1056"></a>        if (child.wasDisabled) {
<a name="line1057"></a>          delete child.wasDisabled;
<a name="line1058"></a>        } else {
<a name="line1059"></a>          child.setEnabled(true);
<a name="line1060"></a>        }
<a name="line1061"></a>      });
<a name="line1062"></a>    } else {
<a name="line1063"></a>      // Disable children first, then flag the container as disabled.  This is
<a name="line1064"></a>      // because controls can&#39;t be disabled if their parent is already disabled.
<a name="line1065"></a>      this.forEachChild(function(child) {
<a name="line1066"></a>        // Disable child control, or flag it if it&#39;s already disabled.
<a name="line1067"></a>        if (child.isEnabled()) {
<a name="line1068"></a>          child.setEnabled(false);
<a name="line1069"></a>        } else {
<a name="line1070"></a>          child.wasDisabled = true;
<a name="line1071"></a>        }
<a name="line1072"></a>      });
<a name="line1073"></a>      this.enabled_ = false;
<a name="line1074"></a>      this.setMouseButtonPressed(false);
<a name="line1075"></a>    }
<a name="line1076"></a>
<a name="line1077"></a>    if (this.isFocusable()) {
<a name="line1078"></a>      // Enable keyboard access only for enabled &amp; visible components.
<a name="line1079"></a>      this.renderer_.enableTabIndex(this.getKeyEventTarget(),
<a name="line1080"></a>          enable &amp;&amp; this.visible_);
<a name="line1081"></a>    }
<a name="line1082"></a>  }
<a name="line1083"></a>};
<a name="line1084"></a>
<a name="line1085"></a>
<a name="line1086"></a>/**
<a name="line1087"></a> * Returns true if the container is focusable, false otherwise.  The default
<a name="line1088"></a> * is true.  Focusable containers always have a tab index and allocate a key
<a name="line1089"></a> * handler to handle keyboard events while focused.
<a name="line1090"></a> * @return {boolean} Whether the component is focusable.
<a name="line1091"></a> */
<a name="line1092"></a>goog.ui.Container.prototype.isFocusable = function() {
<a name="line1093"></a>  return this.focusable_;
<a name="line1094"></a>};
<a name="line1095"></a>
<a name="line1096"></a>
<a name="line1097"></a>/**
<a name="line1098"></a> * Sets whether the container is focusable.  The default is true.  Focusable
<a name="line1099"></a> * containers always have a tab index and allocate a key handler to handle
<a name="line1100"></a> * keyboard events while focused.
<a name="line1101"></a> * @param {boolean} focusable Whether the component is to be focusable.
<a name="line1102"></a> */
<a name="line1103"></a>goog.ui.Container.prototype.setFocusable = function(focusable) {
<a name="line1104"></a>  if (focusable != this.focusable_ &amp;&amp; this.isInDocument()) {
<a name="line1105"></a>    this.enableFocusHandling_(focusable);
<a name="line1106"></a>  }
<a name="line1107"></a>  this.focusable_ = focusable;
<a name="line1108"></a>  if (this.enabled_ &amp;&amp; this.visible_) {
<a name="line1109"></a>    this.renderer_.enableTabIndex(this.getKeyEventTarget(), focusable);
<a name="line1110"></a>  }
<a name="line1111"></a>};
<a name="line1112"></a>
<a name="line1113"></a>
<a name="line1114"></a>/**
<a name="line1115"></a> * Returns true if the container allows children to be focusable, false
<a name="line1116"></a> * otherwise.  Only effective if the container is not focusable.
<a name="line1117"></a> * @return {boolean} Whether children should be focusable.
<a name="line1118"></a> */
<a name="line1119"></a>goog.ui.Container.prototype.isFocusableChildrenAllowed = function() {
<a name="line1120"></a>  return this.allowFocusableChildren_;
<a name="line1121"></a>};
<a name="line1122"></a>
<a name="line1123"></a>
<a name="line1124"></a>/**
<a name="line1125"></a> * Sets whether the container allows children to be focusable, false
<a name="line1126"></a> * otherwise.  Only effective if the container is not focusable.
<a name="line1127"></a> * @param {boolean} focusable Whether the children should be focusable.
<a name="line1128"></a> */
<a name="line1129"></a>goog.ui.Container.prototype.setFocusableChildrenAllowed = function(focusable) {
<a name="line1130"></a>  this.allowFocusableChildren_ = focusable;
<a name="line1131"></a>};
<a name="line1132"></a>
<a name="line1133"></a>
<a name="line1134"></a>/**
<a name="line1135"></a> * @return {boolean} Whether highlighting a child component should also open it.
<a name="line1136"></a> */
<a name="line1137"></a>goog.ui.Container.prototype.isOpenFollowsHighlight = function() {
<a name="line1138"></a>  return this.openFollowsHighlight_;
<a name="line1139"></a>};
<a name="line1140"></a>
<a name="line1141"></a>
<a name="line1142"></a>/**
<a name="line1143"></a> * Sets whether highlighting a child component should also open it.
<a name="line1144"></a> * @param {boolean} follow Whether highlighting a child component also opens it.
<a name="line1145"></a> */
<a name="line1146"></a>goog.ui.Container.prototype.setOpenFollowsHighlight = function(follow) {
<a name="line1147"></a>  this.openFollowsHighlight_ = follow;
<a name="line1148"></a>};
<a name="line1149"></a>
<a name="line1150"></a>
<a name="line1151"></a>// Highlight management.
<a name="line1152"></a>
<a name="line1153"></a>
<a name="line1154"></a>/**
<a name="line1155"></a> * Returns the index of the currently highlighted item (-1 if none).
<a name="line1156"></a> * @return {number} Index of the currently highlighted item.
<a name="line1157"></a> */
<a name="line1158"></a>goog.ui.Container.prototype.getHighlightedIndex = function() {
<a name="line1159"></a>  return this.highlightedIndex_;
<a name="line1160"></a>};
<a name="line1161"></a>
<a name="line1162"></a>
<a name="line1163"></a>/**
<a name="line1164"></a> * Highlights the item at the given 0-based index (if any).  If another item
<a name="line1165"></a> * was previously highlighted, it is un-highlighted.
<a name="line1166"></a> * @param {number} index Index of item to highlight (-1 removes the current
<a name="line1167"></a> *     highlight).
<a name="line1168"></a> */
<a name="line1169"></a>goog.ui.Container.prototype.setHighlightedIndex = function(index) {
<a name="line1170"></a>  var child = this.getChildAt(index);
<a name="line1171"></a>  if (child) {
<a name="line1172"></a>    child.setHighlighted(true);
<a name="line1173"></a>  } else if (this.highlightedIndex_ &gt; -1) {
<a name="line1174"></a>    this.getHighlighted().setHighlighted(false);
<a name="line1175"></a>  }
<a name="line1176"></a>};
<a name="line1177"></a>
<a name="line1178"></a>
<a name="line1179"></a>/**
<a name="line1180"></a> * Highlights the given item if it exists and is a child of the container;
<a name="line1181"></a> * otherwise un-highlights the currently highlighted item.
<a name="line1182"></a> * @param {goog.ui.Control} item Item to highlight.
<a name="line1183"></a> */
<a name="line1184"></a>goog.ui.Container.prototype.setHighlighted = function(item) {
<a name="line1185"></a>  this.setHighlightedIndex(this.indexOfChild(item));
<a name="line1186"></a>};
<a name="line1187"></a>
<a name="line1188"></a>
<a name="line1189"></a>/**
<a name="line1190"></a> * Returns the currently highlighted item (if any).
<a name="line1191"></a> * @return {goog.ui.Control?} Highlighted item (null if none).
<a name="line1192"></a> */
<a name="line1193"></a>goog.ui.Container.prototype.getHighlighted = function() {
<a name="line1194"></a>  return this.getChildAt(this.highlightedIndex_);
<a name="line1195"></a>};
<a name="line1196"></a>
<a name="line1197"></a>
<a name="line1198"></a>/**
<a name="line1199"></a> * Highlights the first highlightable item in the container
<a name="line1200"></a> */
<a name="line1201"></a>goog.ui.Container.prototype.highlightFirst = function() {
<a name="line1202"></a>  this.highlightHelper(function(index, max) {
<a name="line1203"></a>    return (index + 1) % max;
<a name="line1204"></a>  }, this.getChildCount() - 1);
<a name="line1205"></a>};
<a name="line1206"></a>
<a name="line1207"></a>
<a name="line1208"></a>/**
<a name="line1209"></a> * Highlights the last highlightable item in the container.
<a name="line1210"></a> */
<a name="line1211"></a>goog.ui.Container.prototype.highlightLast = function() {
<a name="line1212"></a>  this.highlightHelper(function(index, max) {
<a name="line1213"></a>    index--;
<a name="line1214"></a>    return index &lt; 0 ? max - 1 : index;
<a name="line1215"></a>  }, 0);
<a name="line1216"></a>};
<a name="line1217"></a>
<a name="line1218"></a>
<a name="line1219"></a>/**
<a name="line1220"></a> * Highlights the next highlightable item (or the first if nothing is currently
<a name="line1221"></a> * highlighted).
<a name="line1222"></a> */
<a name="line1223"></a>goog.ui.Container.prototype.highlightNext = function() {
<a name="line1224"></a>  this.highlightHelper(function(index, max) {
<a name="line1225"></a>    return (index + 1) % max;
<a name="line1226"></a>  }, this.highlightedIndex_);
<a name="line1227"></a>};
<a name="line1228"></a>
<a name="line1229"></a>
<a name="line1230"></a>/**
<a name="line1231"></a> * Highlights the previous highlightable item (or the last if nothing is
<a name="line1232"></a> * currently highlighted).
<a name="line1233"></a> */
<a name="line1234"></a>goog.ui.Container.prototype.highlightPrevious = function() {
<a name="line1235"></a>  this.highlightHelper(function(index, max) {
<a name="line1236"></a>    index--;
<a name="line1237"></a>    return index &lt; 0 ? max - 1 : index;
<a name="line1238"></a>  }, this.highlightedIndex_);
<a name="line1239"></a>};
<a name="line1240"></a>
<a name="line1241"></a>
<a name="line1242"></a>/**
<a name="line1243"></a> * Helper function that manages the details of moving the highlight among
<a name="line1244"></a> * child controls in response to keyboard events.
<a name="line1245"></a> * @param {function(number, number) : number} fn Function that accepts the
<a name="line1246"></a> *     current and maximum indices, and returns the next index to check.
<a name="line1247"></a> * @param {number} startIndex Start index.
<a name="line1248"></a> * @return {boolean} Whether the highlight has changed.
<a name="line1249"></a> * @protected
<a name="line1250"></a> */
<a name="line1251"></a>goog.ui.Container.prototype.highlightHelper = function(fn, startIndex) {
<a name="line1252"></a>  // If the start index is -1 (meaning there&#39;s nothing currently highlighted),
<a name="line1253"></a>  // try starting from the currently open item, if any.
<a name="line1254"></a>  var curIndex = startIndex &lt; 0 ?
<a name="line1255"></a>      this.indexOfChild(this.openItem_) : startIndex;
<a name="line1256"></a>  var numItems = this.getChildCount();
<a name="line1257"></a>
<a name="line1258"></a>  curIndex = fn.call(this, curIndex, numItems);
<a name="line1259"></a>  var visited = 0;
<a name="line1260"></a>  while (visited &lt;= numItems) {
<a name="line1261"></a>    var control = this.getChildAt(curIndex);
<a name="line1262"></a>    if (control &amp;&amp; this.canHighlightItem(control)) {
<a name="line1263"></a>      this.setHighlightedIndexFromKeyEvent(curIndex);
<a name="line1264"></a>      return true;
<a name="line1265"></a>    }
<a name="line1266"></a>    visited++;
<a name="line1267"></a>    curIndex = fn.call(this, curIndex, numItems);
<a name="line1268"></a>  }
<a name="line1269"></a>  return false;
<a name="line1270"></a>};
<a name="line1271"></a>
<a name="line1272"></a>
<a name="line1273"></a>/**
<a name="line1274"></a> * Returns whether the given item can be highlighted.
<a name="line1275"></a> * @param {goog.ui.Control} item The item to check.
<a name="line1276"></a> * @return {boolean} Whether the item can be highlighted.
<a name="line1277"></a> * @protected
<a name="line1278"></a> */
<a name="line1279"></a>goog.ui.Container.prototype.canHighlightItem = function(item) {
<a name="line1280"></a>  return item.isVisible() &amp;&amp; item.isEnabled() &amp;&amp;
<a name="line1281"></a>      item.isSupportedState(goog.ui.Component.State.HOVER);
<a name="line1282"></a>};
<a name="line1283"></a>
<a name="line1284"></a>
<a name="line1285"></a>/**
<a name="line1286"></a> * Helper method that sets the highlighted index to the given index in response
<a name="line1287"></a> * to a keyboard event.  The base class implementation simply calls the
<a name="line1288"></a> * {@link #setHighlightedIndex} method, but subclasses can override this
<a name="line1289"></a> * behavior as needed.
<a name="line1290"></a> * @param {number} index Index of item to highlight.
<a name="line1291"></a> * @protected
<a name="line1292"></a> */
<a name="line1293"></a>goog.ui.Container.prototype.setHighlightedIndexFromKeyEvent = function(index) {
<a name="line1294"></a>  this.setHighlightedIndex(index);
<a name="line1295"></a>};
<a name="line1296"></a>
<a name="line1297"></a>
<a name="line1298"></a>/**
<a name="line1299"></a> * Returns the currently open (expanded) control in the container (null if
<a name="line1300"></a> * none).
<a name="line1301"></a> * @return {goog.ui.Control?} The currently open control.
<a name="line1302"></a> */
<a name="line1303"></a>goog.ui.Container.prototype.getOpenItem = function() {
<a name="line1304"></a>  return this.openItem_;
<a name="line1305"></a>};
<a name="line1306"></a>
<a name="line1307"></a>
<a name="line1308"></a>/**
<a name="line1309"></a> * Returns true if the mouse button is pressed, false otherwise.
<a name="line1310"></a> * @return {boolean} Whether the mouse button is pressed.
<a name="line1311"></a> */
<a name="line1312"></a>goog.ui.Container.prototype.isMouseButtonPressed = function() {
<a name="line1313"></a>  return this.mouseButtonPressed_;
<a name="line1314"></a>};
<a name="line1315"></a>
<a name="line1316"></a>
<a name="line1317"></a>/**
<a name="line1318"></a> * Sets or clears the &quot;mouse button pressed&quot; flag.
<a name="line1319"></a> * @param {boolean} pressed Whether the mouse button is presed.
<a name="line1320"></a> */
<a name="line1321"></a>goog.ui.Container.prototype.setMouseButtonPressed = function(pressed) {
<a name="line1322"></a>  this.mouseButtonPressed_ = pressed;
<a name="line1323"></a>};
</pre>


</body>
</html>
